#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;
#include <functional>
#include "smart_prt.h"

class A
{
public:
	A(int a = 0)
		:_a(a)
	{
		cout << "A()" << endl;
	}

	~A()
	{
		cout << "~A()" << endl;
	}
private:
	int _a;
};

struct Node
{
	A _arr;
	Node* prve = nullptr;
	Node* next = nullptr;
	int _a = 0;
	int _b = 0;
};

namespace lazy
{

	class instanOnly
	{

	public:

		class GC
		{
		public:
			~GC()
			{
				cout << "~GC()" << endl;
				lazy::instanOnly::Destroy();
			}
			
		};

		static instanOnly& GetOnlyInstan()
		{
			if (!_instan)
			{
				_instan = new instanOnly;

			}
			return *_instan;
			
		}

		static void Destroy()
		{
			
			if (_instan)
			{
				cout << "Destroy()" << endl;
				delete _instan;
				_instan = nullptr;
			}
		}
	private:
		instanOnly() {};
		instanOnly(const instanOnly& ity) = delete;
		instanOnly& operator=(const instanOnly& ity) = delete;

		~instanOnly()
		{
			cout << "~instanOnly()" << endl;
		}
		static instanOnly* _instan;
		static   GC _gc;

	};

	instanOnly* instanOnly::_instan = nullptr;
	instanOnly::GC instanOnly::_gc;
}



//int main()
//{
//
//	my_smart_ptr::shared_ptr<Node> ptr1(new Node);
//	my_smart_ptr::shared_ptr<Node> ptr2(new Node);
//
//	//my_smart_ptr::shared_ptr<Node> ptr3(ptr2);
//
//	ptr1->next = &(*ptr2);
//	ptr2->prve = &(*ptr1);
//
//	cout << &ptr1 << "->" << &(*ptr1) <<"->"<< ptr1->next << endl;
//	cout << &ptr2 << "->" << &(*ptr2) <<"->"<<ptr2->prve << endl;
//
//	return 0;
//}

int main()
{
	lazy::instanOnly::GetOnlyInstan();
	return 0;
}